package com.lagou.study.order.mapper;

import com.lagou.study.order.pojo.Stock;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;

@Repository
public interface StockMapper extends JpaRepository<Stock, Integer> {

    @Transactional
    @Modifying
    @Query(value = "update stock set quantity = quantity - 1", nativeQuery = true)
    void updateQuantity();
}
